﻿using System;
using System.Collections.Generic;
using System.Text;
using Antu.WebControls;
using EluZSProvider;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using System.Web;

namespace WebSys.UI.OfficeFlow
{
    public class FwbuchangGonggoControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        MPPersistence Persistence1; Panel panel1;
        TextBox txt字1, txt字, txt项目, txt被征收人, txt房屋货币补偿款, txt附属补偿, txt其他补偿, txt门牌号, txt货币补偿款, txt第, txt号, txt征收年, txt征收月,
            txt征收日, 字1, 第1, 号1, 项目1, 被征收人1, 被征收人2, 被征收人3, 被征收人4, 房屋货币补偿款1, 附属补偿2, 其他补偿2, 门牌号2, 货币补偿款1, 征收年1, 征收月1, 征收日1;
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            panel1 = (Panel)FindControl("panel1");
            Persistence1 = (MPPersistence)FindControl("Persistence1");
            NameInfo();
            if (!base.Page.IsPostBack)
            {
                Persistence1.Table = "zs_征收补偿决定书";//数据库中对应的表
                Persistence1.Key = "IID";//表的主键列名称
                Persistence1.KeyValue = HttpContext.Current.Request.QueryString["IID"];//主键列的值
                Persistence1.ConnStr = _EluZSDataProvider.GetConnectionString();//数据库连接字符串

            }
            Persistence1.BindControl = panel1;//持久化控件的控制对象为Panel中的所以的字段，panel1是Panel的ID    
            Button Button1 = (Button)FindControl("Button1");
            if (string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["IID"]))
            {
                Button1.Visible = false;
                
            }
            else {
                Button1.Click += new EventHandler(Button1_Click);
            }
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Persistence1.Update();
            base.Page.Response.Redirect("FwbuchangGonggao.aspx?IID=" + base.Page.Request["IID"]);
        }

        protected override void OnPreRender(EventArgs e)
        {

            base.OnPreRender(e);
            TextBox txtIID = (TextBox)FindControl("txtIID");
            txtIID.Text = HttpContext.Current.Request.QueryString["IID"];
            字1.Text = txt字1.Text.Trim();
            第1.Text = txt第.Text.Trim();
            号1.Text = txt号.Text.Trim();
            项目1.Text = txt项目.Text.Trim();
            被征收人1.Text = txt被征收人.Text.Trim();
            被征收人2.Text = txt被征收人.Text.Trim();
            被征收人3.Text = txt被征收人.Text.Trim();
            被征收人4.Text = txt被征收人.Text.Trim();
            房屋货币补偿款1.Text = txt房屋货币补偿款.Text.Trim();
            附属补偿2.Text = txt附属补偿.Text.Trim();
            其他补偿2.Text = txt其他补偿.Text.Trim();
            门牌号2.Text = txt门牌号.Text.Trim();
            货币补偿款1.Text = txt货币补偿款.Text.Trim();
            征收年1.Text = txt征收年.Text.Trim();
            征收月1.Text = txt征收月.Text.Trim();
            征收日1.Text = txt征收日.Text.Trim();
        }

        private void NameInfo()
        {
            txt字1 = (TextBox)panel1.FindControl("txt字");
            txt字 = (TextBox)FindControl("txt字");
            txt项目 = (TextBox)FindControl("txt项目");
            txt被征收人 = (TextBox)FindControl("txt被征收人");
            txt房屋货币补偿款 = (TextBox)FindControl("txt房屋货币补偿款");
            txt附属补偿 = (TextBox)FindControl("txt附属补偿");
            txt其他补偿 = (TextBox)FindControl("txt其他补助");
            txt门牌号 = (TextBox)FindControl("txt门牌号");
            txt货币补偿款 = (TextBox)FindControl("txt货币补偿款");
            txt第 = (TextBox)FindControl("txt第");
            txt号 = (TextBox)FindControl("txt号");
            txt征收年 = (TextBox)FindControl("txt征收年");
            txt征收月 = (TextBox)FindControl("txt征收月");
            txt征收日 = (TextBox)FindControl("txt征收日");

            字1 = (TextBox)FindControl("字1");
            第1 = (TextBox)FindControl("第1");
            号1 = (TextBox)FindControl("号1");
            项目1 = (TextBox)FindControl("项目1");
            被征收人1 = (TextBox)FindControl("被征收人1");
            被征收人2 = (TextBox)FindControl("被征收人2");
            被征收人3 = (TextBox)FindControl("被征收人3");
            被征收人4 = (TextBox)FindControl("被征收人4");
            房屋货币补偿款1 = (TextBox)FindControl("房屋货币补偿款1");
            附属补偿2 = (TextBox)FindControl("附属补偿2");
            其他补偿2 = (TextBox)FindControl("其他补偿2");
            门牌号2 = (TextBox)FindControl("门牌号2");
            货币补偿款1 = (TextBox)FindControl("货币补偿款1");
            征收年1 = (TextBox)FindControl("征收年1");
            征收月1 = (TextBox)FindControl("征收月1");
            征收日1 = (TextBox)FindControl("征收日1");
        }


    }
}
